<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
  <meta charset='utf-8'>
  <title>这是什么平台？</title>
  <link href="../logo.png" rel="shortcut icon" type="image/png" />
</head>

<body>
  <p id="p_info"></p>
  <script>
    function checkPlatform() {
      function isSomethings(name, condition) {
        return (condition ? "✓ " : "✗ ") + name + "<br/>"
      }
      var info = ""
      info += "navigator.userAgent: " + navigator.userAgent + "<br/>"
      info += "navigator.platform: " + navigator.platform + "<br/>"
      info += isSomethings("Windows", /Windows/i.test(navigator.userAgent))
      info += isSomethings("Android", /android/i.test(navigator.userAgent))
      info += isSomethings("iOS", /(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent))
      info += isSomethings("iPhone", /iPhone/i.test(navigator.userAgent))
      info += isSomethings("iPad", /iPad/i.test(navigator.userAgent))
      info += isSomethings("iPod", /iPod/i.test(navigator.userAgent))
      info += isSomethings("Linux' browser", /Linux/i.test(navigator.userAgent))
      info += isSomethings("Linux operating system", /Linux/i.test(navigator.platform))
      info += isSomethings("MicroMessenger", /MicroMessenger/i.test(navigator.userAgent))
      info += isSomethings("Mac", /(Mac|Macintosh)/i.test(navigator.userAgent))

      var lastSupportedMacOSVersion = "10.12.0"



      var isMac = /(Mac|Macintosh)/i.test(navigator.userAgent)
      if (isMac) {
        var txt = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36"
        txt = txt.match(/Mac\sOS\sX\s\d+_\d+_\d+/i)[0]
        var arr0 = txt.substring("Mac OS X ".length).split('_')
        var arr1 = lastSupportedMacOSVersion.split('.')
        if (arr1.length != arr0.length) {
          alert("读取Mac系统版本号失败")
        }
        var versionIsOK = true
        for (var i = 0; i < arr0.length; ++i) {
          if (arr0[i] > arr1[i]) {
            versionIsOK = true
            break;
          }
          else if (arr0[i] < arr1[i]) {
            versionIsOK = false
            break;
          }
        }
        console.log("versionIsOK", versionIsOK)
      }
      document.getElementById("p_info").innerHTML = info
    }
    checkPlatform()
  </script>
</body>

</html>